/*
 * @Author       : NaN 353362604@qq.com
 * @Date         : 2023-05-15 14:39:01
 * @LastEditTime : 2023-08-11 08:52:27
 * @LastEditors  : NaN 353362604@qq.com
 * @FilePath     : \AdminStration\src\Common\Router\MenuNav\FirstLevel\Device.jsx
 * @Description  :
 */
import { API_LIST } from '../../../Api/Api'

import { commonTableList, BuiltInData } from '../Common/common'
import { AddDataButton, ModDataButton, DelDataButton, OpenTwoRouter } from '../Common/options'

export const Device = async ({ url, OptionsEvent, ClientData, Permission }) => {
    let data = {
        type: '系统配置',
        pageSize: 10,
        params: { pageIndex: 1, OrderField: 'organizationUuid@asc,deviceType@asc' },
        get: API_LIST()[`get${url}`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        options: [
            <AddDataButton OptionsEvent={OptionsEvent} url={url} type="primary" icon="add" title="新增物联网数据" />,
        ],
        columns: [
            commonTableList.uuid,
            { ...commonTableList.organizationUuid, valueEnum: ClientData.organization },
            { ...commonTableList.tableName, width: 400, title: '设备名称' },
            {
                dataIndex: 'deviceType',
                title: '设备类型',
                valueType: 'select',
                valueEnum: BuiltInData.InternetOfThingsType,
                rules: true,
                width: 150,
            },
            {
                dataIndex: 'deviceSerial',
                title: '设备序列号',
                valueType: 'input',
                rules: true,
                width: 150,
            },
            {
                dataIndex: 'location',
                title: '位置',
                valueType: 'input',
                rules: true,
                width: 150,
            },
            {
                dataIndex: 'manager',
                title: '负责人',
                valueType: 'input',
                rules: true,
                width: 150,
            },
            { ...commonTableList.sortId, rules: true },
            commonTableList.createUserName,
            commonTableList.createTime,
            commonTableList.updateUserName,
            commonTableList.updateTime,
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 240,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    return [
                        <ModDataButton OptionsEvent={OptionsEvent} key="modify" title="修改" url={url} data={record} />,
                        <OpenTwoRouter
                            key="TwoOne"
                            title="摄像头列表"
                            modal="TableList"
                            OptionsEvent={OptionsEvent}
                            other={{
                                page: 'Device',
                                Permission,
                                oneData: record,
                                header: data.columns,
                            }}
                        />,
                        <DelDataButton
                            OptionsEvent={OptionsEvent}
                            key="delete"
                            title="删除"
                            url={url}
                            uuid={record.uuid}
                        />,
                    ]
                },
            },
        ],
    }

    return data
}
